-
Notifications
You must be signed in to change notification settings - Fork 22
Adding Kernel PCovC Code #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
82aa115
to
9e4e3d8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good. In general, I like to keep PR's single purpose (@ceriottm will tell you I can be quite vigilant). The changes to PCovC seem small enough, however. I'd just go through and finalize a couple reformatting things then we should be good.
Number of components to keep. | ||
if n_components is not set all components are kept:: | ||
n_components == n_samples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be inline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
classifier: `estimator object` or `precomputed`, default=None | ||
classifier for computing :math:`{\mathbf{Z}}`. The classifier should be one of | ||
`sklearn.linear_model.LogisticRegression`, `sklearn.linear_model.LogisticRegressionCV`, | ||
`sklearn.svm.LinearSVC`, `sklearn.discriminant_analysis.LinearDiscriminantAnalysis`, | ||
`sklearn.linear_model.RidgeClassifier`, `sklearn.linear_model.RidgeClassifierCV`, | ||
`sklearn.linear_model.SGDClassifier`, or `Perceptron`. | ||
If a pre-fitted classifier is provided, it is used to compute :math:`{\mathbf{Z}}`. | ||
If None, ``sklearn.linear_model.LogisticRegression()`` | ||
is used as the classifier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is formatted weird in the docs, is there any other way we can do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed this to be a list for both KPCovC and PCovC (they have the similar docs here).
@@ -76,8 +67,8 @@ class KernelPCovR(_BasePCA, LinearModel): | |||
If `precomputed`, we assume that the `y` passed to the `fit` function | |||
is the regressed form of the targets :math:`{\mathbf{\hat{Y}}}`. | |||
|
|||
kernel : "linear" | "poly" | "rbf" | "sigmoid" | "cosine" | "precomputed" | |||
Kernel. Default="linear". | |||
kernel : {'linear', 'poly', 'rbf', 'sigmoid', 'cosine', 'precomputed'} or callable, default='linear' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the formatting change here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be fine but please use double quotes for strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the vertical bars to match how we format the rest of the parameters that contain a list of options. Added double quotes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I LOVE this example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice. I have some minor styling comments but should be easy to implement.
""" | ||
return super().inverse_transform(T) | ||
|
||
def decision_function(self, X=None, T=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function seems not tested very well. You think you can extend the tests to cover the points codecov is complaining?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point -- we are adding some more tests to this in our next update for multi-output PCovC/KPCovC. For now, I think I will leave it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay should this be doner in another PR? If yes just open an issue to keep track of the TODOs please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rvasav26 I think we should try to add these tests in this PR. These look easy to test.
@@ -76,8 +67,8 @@ class KernelPCovR(_BasePCA, LinearModel): | |||
If `precomputed`, we assume that the `y` passed to the `fit` function | |||
is the regressed form of the targets :math:`{\mathbf{\hat{Y}}}`. | |||
|
|||
kernel : "linear" | "poly" | "rbf" | "sigmoid" | "cosine" | "precomputed" | |||
Kernel. Default="linear". | |||
kernel : {'linear', 'poly', 'rbf', 'sigmoid', 'cosine', 'precomputed'} or callable, default='linear' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be fine but please use double quotes for strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes. I am happy.
examples/pcovc/KPCovC_Comparison.py
Outdated
"kernel_params": {"kernel": "rbf", "gamma": 12}, | ||
"title": "Logistic Regression", | ||
}, | ||
RidgeClassifier(random_state=random_state): { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also use RidgeClassifierCV here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very happy - just left a few comments, and will approve once tests for the kpcovc decision function have been written.
714ea50
to
a1a316a
Compare
Adding Kernel PCovC code, examples, and testing suite. Adding a KPCov base class that both Kernel PCovR and Kernel PCovC inherit from.
Contributor (creator of PR) checklist
For Reviewer
📚 Documentation preview 📚: https://scikit-matter--254.org.readthedocs.build/en/254/